﻿
<UserControl x:Class="MaxStoreShop.CoreModule.Settings.SettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:security="clr-namespace:MaxStoreErp.Core.Security;assembly=MaxStoreErp.Core"
             xmlns:settings="clr-namespace:MaxStoreShop.CoreModule.Settings"
             d:DataContext="{d:DesignInstance settings:SettingsViewModel}"
             d:DesignHeight="500"
             d:DesignWidth="300"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary Source="../Resources/Images.xaml" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TabControl>
            <TabItem Header="Рабочий каталог приложения">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox Margin="0,0,6,0"
                             VerticalAlignment="Center"
                             IsReadOnly="True"
                             Text="{Binding WorkFolder,
                                            Mode=TwoWay}" />
                    <Button Grid.Column="1"
                            Width="44"
                            Height="44"
                            BorderThickness="0"
                            Command="{Binding BrowseWorkFolderCommand}"
                            IsDefault="True"
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            ToolTip="Обзор директорий">
                        <Path Width="32"
                              Height="32"
                              Data="{StaticResource FolderIcon}"
                              Fill="{DynamicResource BlackBrush}"
                              Stretch="Uniform" />
                    </Button>
                </Grid>
            </TabItem>
        </TabControl>

        <TabControl Grid.Row="1">
            <TabItem Header="Каталог обновлений">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox Margin="0,0,6,0"
                             VerticalAlignment="Center"
                             IsReadOnly="True"
                             Text="{Binding UpdateFolder,
                                            Mode=TwoWay}" />
                    <Button Grid.Column="1"
                            Width="44"
                            Height="44"
                            BorderThickness="0"
                            Command="{Binding BrowseUpdateFolderCommand}"
                            IsDefault="True"
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            ToolTip="Обзор директорий">
                        <Path Width="32"
                              Height="32"
                              Data="{StaticResource FolderIcon}"
                              Fill="{DynamicResource BlackBrush}"
                              Stretch="Uniform" />
                    </Button>
                </Grid>
            </TabItem>
        </TabControl>

        <TabControl Grid.Row="2">
            <TabItem Header="База данных">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Text="Имя сервера:" />
                    <TextBox Grid.Row="1"
                             Margin="2"
                             VerticalAlignment="Center"
                             Text="{Binding ServerName,
                                            Mode=TwoWay,
                                            UpdateSourceTrigger=LostFocus}" />
                    <GroupBox Grid.Row="2"
                              Margin="2,12,2,12"
                              Header="Авторизация">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <RadioButton Name="NtSecurityRadioButton"
                                         Margin="2"
                                         Content="Использовать встроенную безопасность Windows NT"
                                         IsChecked="True" />
                            <RadioButton Name="UserSecurityRadioButton"
                                         Grid.Row="1"
                                         Margin="2"
                                         Content="Использовать имя пользователя и пароль" />
                            <Grid Grid.Row="2" IsEnabled="{Binding ElementName=UserSecurityRadioButton, Path=IsChecked}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <TextBlock Margin="2" Text="Имя пользователя:" />
                                <TextBox Grid.Row="0"
                                         Grid.Column="1"
                                         Margin="2"
                                         Text="{Binding UserId,
                                                        Mode=TwoWay,
                                                        UpdateSourceTrigger=LostFocus}" />
                                <TextBlock Grid.Row="1"
                                           Grid.Column="0"
                                           Margin="2"
                                           Text="Пароль:" />
                                <PasswordBox x:Name="PasswordTextBox"
                                             Grid.Row="1"
                                             Grid.Column="1"
                                             Margin="2"
                                             TabIndex="2"
                                             security:PasswordBoxAssistant.BindPassword="true"
                                             security:PasswordBoxAssistant.BoundPassword="{Binding Path=Password,
                                                                                                   Mode=TwoWay,
                                                                                                   UpdateSourceTrigger=LostFocus}" />
                            </Grid>
                            <Button Grid.Row="3"
                                    Width="44"
                                    Height="44"
                                    BorderThickness="0"
                                    Command="{Binding CheckConnectionCommand}"
                                    IsDefault="True"
                                    Style="{DynamicResource MetroCircleButtonStyle}"
                                    ToolTip="Проверка соединения">
                                <Path Width="32"
                                      Height="32"
                                      Data="{StaticResource CheckConnectionIcon}"
                                      Fill="{DynamicResource BlackBrush}"
                                      Stretch="Uniform" />
                            </Button>
                        </Grid>
                    </GroupBox>
                    <TextBlock Grid.Row="3"
                               Margin="2"
                               Text="Имя базы данных:" />
                    <TextBox Grid.Row="4"
                             Margin="2"
                             Text="{Binding DataBaseName,
                                            Mode=TwoWay,
                                            UpdateSourceTrigger=LostFocus}" />
                </Grid>
            </TabItem>

        </TabControl>
    </Grid>
</UserControl>
